package com.hsmw.api.controller.biz;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.util.concurrent.AtomicDouble;
import com.hsmw.api.mapper.*;
import com.hsmw.api.service.*;
import com.hsmw.api.utils.GaoDeInfoUtils;
import com.hsmw.api.vo.HomeVolume;
import com.hsmw.api.vo.VehicleDetailInfo;
import com.htn.common.core.base.DataResponse;
import com.htn.common.core.constant.*;
import com.htn.common.core.utils.StringUtils;
import com.hsmw.domain.*;
import com.hsmw.domain.form.GetObjectByIdForm;
import com.hsmw.domain.vo.GpsInfoEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;

import static java.util.stream.Collectors.toList;

/**
 * @author WD
 */
@Api(tags = "BIZ-首页")
@RestController
@RequestMapping("/api/biz/home")
public class BizHomeController {

	@Autowired
	private HsmwOrderMapper hsmwOrderMapper;

	@Autowired
	private HsmwOrderVehicleRelationMapper hsmwOrderVehicleRelationMapper;

	@Autowired
	private HsmwAuditMapper hsmwAuditMapper;

	@Autowired
	private HsmwVehicleRefuelingService hsmwVehicleRefuelingService;

	@Autowired
	private HsmwVehicleMapper hsmwVehicleMapper;

	@Autowired
	private HsmwItemMapper hsmwItemMapper;
	@Autowired
	private HsmwUserDriverMapper hsmwUserDriverMapper;

	@Autowired
	private HsmwUserMapper hsmwUserMapper;

	@Autowired
	private HsmwVehicleService hsmwVehicleService;

	@Autowired
	private HsmwComplainService hsmwComplainService;

	@Autowired
	private HsmwReportService hsmwReportService;

	@Autowired
	private HsmwComplainMapper hsmwComplainMapper;

	@Autowired
	private HsmwConcretePlantInfoService hsmwConcretePlantInfoService;


	@Autowired
	private HsmwReportInfoMapper hsmwReportInfoMapper;

	@Autowired
	private HsmwExamineRecordMapper hsmwExamineRecordMapper;


	@Autowired
	private HsmwOtherNoticeInfoMapper hsmwOtherNoticeInfoMapper;



	@Autowired
	private HsmwPmUserService hsmwPmUserService;

	@Autowired
	private HsmwConcreteUserService hsmwConcreteUserService;

	@Autowired
	private HsmwDriverUserService hsmwDriverUserService;

	@Autowired
	private HsmwBizUserService hsmwBizUserService;

	@Autowired
	private HsmwHtnUserService hsmwHtnUserService;

	@Autowired
	private HsmwTpspUserService hsmwTpspUserService;

	@Autowired
	private HsmwSaleUserService hsmwSaleUserService;


	@Autowired
	private HsmwPmUserMapper hsmwPmUserMapper;

	@Autowired
	private HsmwConcreteUserMapper hsmwConcreteUserMapper;

	@Autowired
	private HsmwDriverUserMapper hsmwDriverUserMapper;

	@Autowired
	private HsmwBizUserMapper hsmwBizUserMapper;

	@Autowired
	private HsmwHtnUserMapper hsmwHtnUserMapper;

	@Autowired
	private HsmwTpspUserMapper hsmwTpspUserMapper;

	@Autowired
	private HsmwSaleUserMapper hsmwSaleUserMapper;




	/**
	 * 数据总览+待办事项接口
	 */
	@ApiOperation(value = "首页接口", notes = "数据总览+待办事项接口", produces = "application/json")
	@PostMapping("/getHomeData")
	public DataResponse getHomeData() {
		Map<String, Object> resultMap = Maps.newHashMap();
		List<HsmwAudit> hsmwAuditList = hsmwAuditMapper.selectList(Wrappers.lambdaQuery(HsmwAudit.class).eq(HsmwAudit::getAuditStatus, CommonConstants.AUDIT_ING).orderByDesc(HsmwAudit::getCreateTime));
		resultMap.put("hsmwAuditList", hsmwAuditList);
		/**
		 * 今日订单
		 */
		Integer allCount = hsmwOrderMapper.selectCount(
				Wrappers.lambdaQuery(HsmwOrder.class)
						.between(HsmwOrder::getCreateTime, DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date()))
		);
		/**
		 * 方量
		 */
		//本月
		Double monthVolume = hsmwOrderVehicleRelationMapper.findSumRealVolume();
		resultMap.put("monthVolume", monthVolume);
		/**
		 * 订单走势
		 */
		List<JSONObject> orderTrend = Lists.newArrayList();
		LocalDate localDate = LocalDate.now();
		//这个月的第一天
		Date monthStart = Date.from(localDate.with(TemporalAdjusters.firstDayOfMonth()).atStartOfDay(ZoneId.systemDefault()).toInstant());
		//这个月的最后一天 下个月的第一天
		Date monthEnd = Date.from(localDate.plusMonths(1).with(TemporalAdjusters.firstDayOfMonth()).atStartOfDay(ZoneId.systemDefault()).toInstant());

		DateTime endTime = DateUtil.date(monthEnd);
		DateTime startTime = DateUtil.date(monthStart);
		List<HsmwOrder> hsmwOrderList = hsmwOrderMapper.selectList(
				Wrappers.lambdaQuery(HsmwOrder.class)
						.between(HsmwOrder::getEndTime, DateUtil.beginOfDay(startTime), DateUtil.endOfDay(endTime)).eq(HsmwOrder::getOrderStatus, OrderStatusEnum.COMPLETED.getValue())
		);
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(endTime);
		calendar.add(Calendar.DATE,-1);
		Date dateEndtime =calendar.getTime();
		hsmwOrderList.forEach(x -> x.setStatisticsTime(DateUtil.format(Date.from(x.getEndTime().atZone(ZoneId.systemDefault()).toInstant()), "yyyy-MM-dd")));
		Map<String, List<HsmwOrder>> statisticsMap = hsmwOrderList.stream().collect(Collectors.groupingBy(HsmwOrder::getStatisticsTime));
		List<String> dayBetween = com.htn.common.core.utils.DateUtil.getDayBetween(DateUtil.format(startTime.toJdkDate(), "yyyy-MM-dd"), DateUtil.format(dateEndtime, "yyyy-MM-dd"));
		dayBetween.forEach(day -> {
			AtomicInteger count = new AtomicInteger();
			JSONObject jsonObject = new JSONObject();
			jsonObject.put("day", day);
			if (statisticsMap.get(day) != null) {
				List<HsmwOrder> orderList = statisticsMap.get(day);
				orderList.stream().forEach(x->{
					if(StrUtil.isNotBlank(x.getForemanVolume())){
						count.addAndGet(Integer.valueOf(x.getForemanVolume()));
					}
				});
			}
			jsonObject.put("count", count);
			orderTrend.add(jsonObject);
		});
		resultMap.put("orderTrend", orderTrend);
		/*//已完成数量
		resultMap.put("completeCount",hsmwOrderList.size());
		List<HsmwOrder> 	unCompleteHsmwOrderList = hsmwOrderMapper.selectList(
				Wrappers.lambdaQuery(HsmwOrder.class)
						.between(HsmwOrder::getEndTime, DateUtil.beginOfDay(startTime), DateUtil.endOfDay(endTime)).in(HsmwOrder::getOrderStatus, new String[]{MainOrderStatusEnum.CREATESUCCESS.getValue(), MainOrderStatusEnum.ENDED.getValue(),MainOrderStatusEnum.GOING.getValue()}));
		//未完成数量
		resultMap.put("unCompleteCount",CollectionUtil.isEmpty(unCompleteHsmwOrderList) ? 0: unCompleteHsmwOrderList.size());*/
		//泵车数量
		List<HsmwVehicle> vehicles =hsmwVehicleMapper.selectList(new LambdaQueryWrapper<>());
		resultMap.put("vehicleCount",CollectionUtil.isEmpty(vehicles) ? 0: vehicles.size());
		//司机数量
		List<HsmwUserDriver>  drivers  =hsmwUserDriverMapper.selectList(new LambdaQueryWrapper<>());
		resultMap.put("driverCount",CollectionUtil.isEmpty(drivers) ? 0: drivers.size());
		//工长数量
		List<HsmwHtnUser> hsmwUsers = hsmwHtnUserService.
				list(new LambdaQueryWrapper<HsmwHtnUser>().eq(HsmwHtnUser::getType, HtnUserTypeEnum.FOREMAN.getValue()));
		resultMap.put("foremanCount",CollectionUtil.isEmpty(hsmwUsers) ? 0: hsmwUsers.size());
		//项目数量
		List<HsmwItem> items  =hsmwItemMapper.selectList(new LambdaQueryWrapper<HsmwItem>().eq(HsmwItem::getAuditStatus, AuditStatusEnum.RECEIVED.getValue()));
		resultMap.put("itemCount",CollectionUtil.isEmpty(items) ? 0: items.size());
		//待审核司机数量
		List<HsmwAudit> audits = hsmwAuditMapper.selectList(new LambdaQueryWrapper<HsmwAudit>()
				.eq(HsmwAudit::getAuditStatus,AuditStatusEnum.UNRECEIVED.getName()));
		resultMap.put("unReceivedDriverCount", CollectionUtil.isEmpty(audits) ? 0: audits.size());
		//待审核项目数量

		List<HsmwItem> unReceivedItem = hsmwItemMapper.selectList(new LambdaQueryWrapper<HsmwItem>()
				.eq(HsmwItem::getAuditStatus,AuditStatusEnum.UNRECEIVED.getValue()));
		resultMap.put("unReceivedItemCount",CollectionUtil.isEmpty(unReceivedItem) ? 0: unReceivedItem.size());
		//待审核工长数量
		List<HsmwHtnUser> unReceivedForeman= hsmwHtnUserService.list(new LambdaQueryWrapper<HsmwHtnUser>()
				.eq(HsmwHtnUser::getType,UserTypeEnum.VISITOR)
				.eq(HsmwHtnUser::getAuditStatus,AuditStatusEnum.UNRECEIVED.getValue()));
		resultMap.put("unReceivedForemanCount",CollectionUtil.isEmpty(unReceivedForeman) ? 0: unReceivedForeman.size());
		// 搅拌站数量
		List<HsmwConcretePlantInfo> plantInfos = hsmwConcretePlantInfoService.list();
		resultMap.put("plantInfosCount",CollectionUtil.isEmpty(plantInfos) ? 0: plantInfos.size());

		//车辆列表
		List<HsmwVehicle> list = hsmwVehicleService.list();
		for (HsmwVehicle hsmwVehicle : list) {
			if(StringUtils.isNotBlank(hsmwVehicle.getImeiNum()) || StringUtils.isNotBlank(hsmwVehicle.getIdentifyingCode())){
				GpsInfoEntity entity = GaoDeInfoUtils.getSingleVehicleGpsLocate(hsmwVehicle.getImeiNum(),hsmwVehicle.getFlag(),hsmwVehicle.getIdentifyingCode());
				if(StringUtils.isNotNull(entity) && StringUtils.isNotBlank(entity.getGpsLon())){
					hsmwVehicle.setImeiNumLocate(entity.getGpsLon()+","+entity.getGpsLat());
					if(StringUtils.isNotBlank(hsmwVehicle.getImeiNumLocate())){
						String nameByGps = GaoDeInfoUtils.gaodeGetNameByGps(hsmwVehicle.getImeiNumLocate());
						hsmwVehicle.setVehicleAddress(nameByGps);
					}
				}
			}else {
				hsmwVehicle.setImeiNumLocate(hsmwVehicle.getMobileLocate());
				String nameByGps = GaoDeInfoUtils.gaodeGetNameByGps(hsmwVehicle.getImeiNumLocate());
				hsmwVehicle.setVehicleAddress(nameByGps);
			}
		}
		resultMap.put("vehicleList",list);
		/**
		 * 代办事项
		 */
		Map map = new HashMap();
		List<HsmwReport> hsmwReports = hsmwReportService.list(new LambdaQueryWrapper<HsmwReport>().eq(HsmwReport::getExamineType, "0"));
		List<HsmwItem> hsmwItems = hsmwItemMapper.selectList(new LambdaQueryWrapper<HsmwItem>().eq(HsmwItem::getAuditStatus, "1"));
		List<HsmwComplain> hsmwComplains = hsmwComplainService.list(new LambdaQueryWrapper<HsmwComplain>().eq(HsmwComplain::getComplainStatus, "0"));
		List<HsmwHtnUser> user = hsmwHtnUserService.list(new LambdaQueryWrapper<HsmwHtnUser>().eq(HsmwHtnUser::getForemanType, "0").eq(HsmwHtnUser::getAuditStatus, "1"));
		List<HsmwAudit> audit = hsmwAuditMapper.selectList(new LambdaQueryWrapper<HsmwAudit>().eq(HsmwAudit::getAuditStatus, "审核中"));
		map.put("audit",audit);
		map.put("retail",user);
		map.put("hsmwReports",hsmwReports);
		map.put("hsmwItems",hsmwItems);
		map.put("hsmwComplains",hsmwComplains);
		resultMap.put("agencyMatters",map);

		return new DataResponse(resultMap);
	}


	/**
	 * 根据id查询车辆数据
	 *
	 * @param form
	 * @return
	 */
	@ApiOperation(value = "根据车辆ID查询车辆数据", notes = "根据车辆ID查询车辆数据", produces = "application/json")
	@PostMapping("/getHsmwVehicleInfoById")
	public DataResponse getVehicleById(@RequestBody GetObjectByIdForm form) {
		HashMap param = new HashMap();
		param.put("vehicleId",form.getKey());
		VehicleDetailInfo info  = hsmwVehicleMapper.getVehicleDetailInfo(param);
		return new DataResponse(info);
	}


	/**
	 * 方量统计 按周 月 年 分组
	 */
	@ApiOperation(value = "方量统计 按周 月 年 分组", notes = "方量统计 按周 月 年 分组", produces = "application/json")
	@ApiImplicitParam(name = "params", value = "按周:1 月:2 年:3 分组", dataType = "String")
	@PostMapping("statisticalGrouping")
	public DataResponse statisticalGrouping(String params) {

		if (StringUtils.isBlank(params)) {
			return new DataResponse(CommonConstants.ResponseStatus.FAIL, "参数错误");
		}
		Map map = new HashMap();
		/**
		 * 周
		 *
		 */
		if (StringUtils.equals("1", params)) {
			List<HomeVolume> homeVolumes = hsmwOrderMapper.findForeManVolumeWeek();
			AtomicReference<Long> sumCount = new AtomicReference<>(0L);
			homeVolumes.stream().forEach(homeVolume -> {
				String[] weekDays = { "周天", "周一", "周二", "周三", "周四", "周五", "周六" };
				Calendar cal = Calendar.getInstance();
				Date date = new Date();
				cal.setTime(date.from(homeVolume.getEndTime().atZone( ZoneId.systemDefault()).toInstant()));
				int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
				if (w < 0)
					w = 0;
				homeVolume.setWeekName(weekDays[w]);
				if(homeVolume.getForemanVolume() == null){
					homeVolume.setForemanVolume("0");
				}
				sumCount.updateAndGet(v -> v + Double.valueOf(homeVolume.getForemanVolume()).longValue());
			});
			map.put("orderTrend",homeVolumes);
			map.put("sumCount",sumCount.get());
		}

		/**
		 * 月
		 */
		if (StringUtils.equals("2", params)) {
			List<JSONObject> orderTrend = Lists.newArrayList();
			LocalDate localDate = LocalDate.now();
			//这个月的第一天
			Date monthStart = Date.from(localDate.with(TemporalAdjusters.firstDayOfMonth()).atStartOfDay(ZoneId.systemDefault()).toInstant());
			//这个月的最后一天 下个月的第一天
			Date monthEnd = Date.from(localDate.plusMonths(1).with(TemporalAdjusters.firstDayOfMonth()).atStartOfDay(ZoneId.systemDefault()).toInstant());

			DateTime endTime = DateUtil.date(monthEnd);
			DateTime startTime = DateUtil.date(monthStart);
			List<HsmwOrderVehicleRelation> hsmwOrderList = hsmwOrderVehicleRelationMapper.selectList(
					Wrappers.lambdaQuery(HsmwOrderVehicleRelation.class)
							.between(HsmwOrderVehicleRelation::getEndTime, DateUtil.beginOfDay(startTime), DateUtil.endOfDay(endTime)).eq(HsmwOrderVehicleRelation::getOrderStatus, ChildOrderStatusEnum.COMPLETED.getValue())
			);
			hsmwOrderList.forEach(x -> x.setStatisticsTime(DateUtil.format(Date.from(x.getEndTime().atZone(ZoneId.systemDefault()).toInstant()), "yyyy-MM-dd")));
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(endTime);
			calendar.add(Calendar.DATE,-1);
			Date dateEndtime =calendar.getTime();
			Map<String, List<HsmwOrderVehicleRelation>> statisticsMap = hsmwOrderList.stream().collect(Collectors.groupingBy(HsmwOrderVehicleRelation::getStatisticsTime));
			List<String> dayBetween = com.htn.common.core.utils.DateUtil.getDayBetween(DateUtil.format(startTime.toJdkDate(), "yyyy-MM-dd"), DateUtil.format(dateEndtime, "yyyy-MM-dd"));

			for (String day : dayBetween) {
				AtomicDouble count = new AtomicDouble();
				JSONObject jsonObject = new JSONObject();
				jsonObject.put("weekName", day);
				if (statisticsMap.get(day) != null) {
					List<HsmwOrderVehicleRelation> orderList = statisticsMap.get(day);
					orderList.stream().forEach(x -> {
						if (StrUtil.isNotBlank(x.getDriverVolume())) {
							String foremanVolume = x.getDriverVolume();
							count.addAndGet(Double.valueOf(foremanVolume));
						}
					});
				}
				jsonObject.put("foremanVolume", count);
				orderTrend.add(jsonObject);
			}
			map.put("orderTrend",orderTrend);
			AtomicReference<Double> sumCount = new AtomicReference<>(0.0);
			hsmwOrderList.stream().forEach(hsmwOrder -> {
				if(hsmwOrder.getDriverVolume() == null){
					hsmwOrder.setDriverVolume(String.valueOf(0));
				}
				sumCount.updateAndGet(v -> v + Double.parseDouble(hsmwOrder.getDriverVolume()));
			});
			map.put("sumCount",sumCount.get());
		}

		/**
		 * 年
		 */
		if (StringUtils.equals("3", params)) {
			List<HomeVolume> homeVolumes = hsmwOrderMapper.findForeManVolumeMonth();
			System.err.println(homeVolumes.size());
			AtomicReference<Double> sumCount = new AtomicReference<>(0.0);
			homeVolumes.stream().forEach(homeVolume -> {
				if(StringUtils.isNotBlank(homeVolume.getForemanVolume())){
					sumCount.updateAndGet(v -> v + Double.valueOf(homeVolume.getForemanVolume()).doubleValue());
				}
			});
			map.put("sumCount",String.format("%.1f",sumCount.get()));
			map.put("homeVolumes",homeVolumes);
		}

		return new DataResponse(map);
	}



		/**
         * 投诉统计 按周 月 年 分组
         */
	@ApiOperation(value = "投诉统计 按周 月 年 分组", notes = "投诉统计 按周 月 年 分组", produces = "application/json")
	@ApiImplicitParam(name = "params", value = "按周:1 月:2 年:3 分组", dataType = "String")
	@PostMapping("statisticalComplaint")
	public DataResponse statisticalComplaint(String params) {

		if (StringUtils.isBlank(params)) {
			return new DataResponse(CommonConstants.ResponseStatus.FAIL, "参数错误");
		}
		Map map = new HashMap();
		//周
		if (StringUtils.equals("1", params)) {

			List<HomeVolume> homeVolumes = hsmwComplainService.findCountOnWeek();
			LocalDate listDays = LocalDate.now();
			List<String> localDateList = new ArrayList<>();
			List<LocalDate> localDates = Arrays.asList(DayOfWeek.values()).stream().map(listDays::with).collect(toList());
			for (LocalDate localDate : localDates) {
				DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
				localDateList.add(pattern.format(localDate));
			}
			map.put("homeVolumes", homeVolumes);
			map.put("localDates", localDateList);
		}

		// 月
		if (StringUtils.equals("2", params)) {
			List<HomeVolume> homeVolumes = hsmwComplainService.findCountOnMonth();
			map.put("homeVolumes",homeVolumes);
		}

		//年
		if (StringUtils.equals("3", params)) {
			List<HomeVolume> homeVolumes = hsmwComplainService.findCountOnYear();
			map.put("homeVolumes", homeVolumes);
		}

		return new DataResponse(map);
	}


	@ApiOperation(value = "首页项目统计 按周 月 年 分组", notes = "首页项目统计 按周 月 年 分组", produces = "application/json")
	@ApiImplicitParam(name = "params", value = "按周:1 月:2 年:3 分组", dataType = "String")
	@PostMapping("statisticalItem")
	public DataResponse statisticalItem(String params) {

		if (StringUtils.isBlank(params)) {
			return new DataResponse(CommonConstants.ResponseStatus.FAIL, "参数错误");
		}
		Map map = new HashMap();
		//周
		if (StringUtils.equals("1", params)) {

			List<HomeVolume> homeVolumes = hsmwItemMapper.findItemVolumeOnWeek();
			map.put("homeVolumes", homeVolumes);
		}

		// 月
		if (StringUtils.equals("2", params)) {
			List<HomeVolume> homeVolumes = hsmwItemMapper.findItemVolumeOnMonth();
			map.put("homeVolumes",homeVolumes);
		}

		//年
		if (StringUtils.equals("3", params)) {
			List<HomeVolume> homeVolumes = hsmwItemMapper.findItemVolumeOnYear();
			map.put("homeVolumes", homeVolumes);
		}

		return new DataResponse(map);
	}

	@ApiOperation(value = "上报 审核 角标", notes = "上报 审核 角标", produces = "application/json")
	@PostMapping("findReportAndAuditNum")
	public DataResponse findReportAndAuditNum(){
		Map map = new HashMap();
		int problemCount = hsmwReportService.count(new LambdaQueryWrapper<HsmwReport>().in(HsmwReport::getReportType, "2", "3", "4","5","6").in(HsmwReport::getExamineType, "0", "2"));
		int leaveCount = hsmwReportService.count(new LambdaQueryWrapper<HsmwReport>().in(HsmwReport::getReportType, "1").in(HsmwReport::getExamineType, "0"));
		int complaintCount = hsmwComplainService.count(new LambdaQueryWrapper<HsmwComplain>().in(HsmwComplain::getComplainStatus, "0"));
		int refuelingCount = hsmwVehicleRefuelingService.count(new LambdaQueryWrapper<HsmwVehicleRefueling>().eq(HsmwVehicleRefueling::getStatus, "0"));
		Integer itemCount = hsmwItemMapper.selectCount(new LambdaQueryWrapper<HsmwItem>().eq(HsmwItem::getAuditStatus, "1"));
		Integer retailCount = hsmwHtnUserMapper.selectCount(new LambdaQueryWrapper<HsmwHtnUser>().eq(HsmwHtnUser::getAuditStatus, "1").eq(HsmwHtnUser::getForemanType,"0"));
		Integer auditCount = hsmwAuditMapper.selectCount(new LambdaQueryWrapper<HsmwAudit>().eq(HsmwAudit::getAuditStatus, "审核中"));
		map.put("problemCount",problemCount);
		map.put("leaveCount",leaveCount);
		map.put("complaintCount",complaintCount);
		map.put("refuelingCount",refuelingCount);
		map.put("itemCount",itemCount);
		map.put("retailCount",retailCount);
		map.put("auditCount",auditCount);
		return new DataResponse(map);
	}

	@ApiOperation(value = "修改中控的上报通知为已读 ", notes = "上报 审核 角标", produces = "application/json")
	@PostMapping("updateNoticeFlag")
	@ApiImplicitParam(name = "params", value = "包括通知类型和 通知ID", dataType = "String")
	public DataResponse updateNoticeFlag(com.alibaba.fastjson.JSONObject  params){
		String type = params.getString("type");
		String noticeId = params.getString("noticeId");

		if("1".equals(type)){
			HsmwExamineRecord record = new HsmwExamineRecord();
			record.setReadFlag(true);
			hsmwExamineRecordMapper.updateById(record);
		}
		if("2".equals(type)){
			HsmwReportInfo record = new HsmwReportInfo();
			record.setReadFlag(true);
			hsmwReportInfoMapper.updateById(record);
		}
		if("3".equals(type)){
			HsmwOtherNoticeInfo record = new HsmwOtherNoticeInfo();
			record.setReadFlag(true);
			hsmwOtherNoticeInfoMapper.updateById(record);
		}
		return new DataResponse();
	}

	public static void main(String[] args) {
		LocalDate listDays = LocalDate.now();
		List<String> localDateList = new ArrayList<>();
		List<LocalDate> localDates = Arrays.asList(DayOfWeek.values()).stream().map(listDays::with).collect(toList());
		System.out.println(localDates);
	}

}
